// Defines a Mathquestion. Contains methods for comparing and saving answers, and for getting the answer and question at hand.
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.question;

/**
 *
 * @author Hanna
 */
public abstract class MathQuestion implements IQuestion {

    protected int answer;
    protected int userAnswer;
    protected String question;
    protected int questionNumber;
    protected boolean answered;

    public boolean isAnswered() {
        return answered;
    }

    public void notAnswered() {
        answered = false;
    }

    public String getQuestion() {
        return question;
    }

    public int getAnswer() {  // gets the correct answer to the question
        return answer;
    }

    public int getUserAnswer() { // gets the user's answer
        return userAnswer;
    }

    public void saveUserAnswer(int userAnswer) { // saves the user's answer
        this.userAnswer = userAnswer;
        answered = true;
    }

    public void questionNumber(int questionNumber) { // the variable "questionumber" is assigned the questionnumber of the question, and returns it
        this.questionNumber = questionNumber;
    }

    public int getQuestionNumber() {
        return questionNumber;
    }

    public boolean compareAnswers() { // compares the question's and the user's answer, and returns true if they're the same, and false otherwise
        if (answer == userAnswer) {
            return true;
        } else {
            return false;
        }
    }
}
